<template>
	<view class='bw_footer'>
		<view class='bw_footer_item' v-for="(v,i) in footer_list" :key='i' @click="switchFooterTab(v)">
			<image :src='v.id===tab?v.icon_active:v.icon' :mode='footer_icon_mode'></image>
			<text :class="{'active':v.id===tab}">{{v.name}}</text>
		</view>
	</view>
</template>

<script>
	const HOME_PAGE = 0
	const MARKET_PAGE = 1
	const DEAL_PAGE = 2
	const ME_PAGE = 3
	export default {
		name: "bw_footer",
		props: {
			tab: {
				type: Number,
				default: HOME_PAGE
			}
		},
		data() {
			return {
				footer_icon_mode: 'aspectFit',
				footer_list: [{
						id: HOME_PAGE,
						name: '首页',
						icon: '/static/image/footer/index.png',
						icon_active: '/static/image/footer/index-active.png',
						path: '/pages/index/index'
					},
					{
						id: MARKET_PAGE,
						name: '市场',
						icon: '/static/image/footer/market.png',
						icon_active: '/static/image/footer/market-active.png',
						path: '/pages/market/market'
					},
					{
						id: DEAL_PAGE,
						name: '交易',
						icon: '/static/image/footer/deal.png',
						icon_active: '/static/image/footer/deal-active.png',
						path: '/pages/deal/deal'
					},
					{
						id: ME_PAGE,
						name: '我的',
						icon: '/static/image/footer/me.png',
						icon_active: '/static/image/footer/me-active.png',
						path: '/pages/me/me'
					},
				],
			}
		},
		methods: {
			switchFooterTab(tab) {
				this.$emit('tabChange', tab.id)
				// uni.navigateTo({
				// 	url: path
				// })
			}
		}
	}
</script>


<style>
	.icon {
		width: 50px;
		height: 27px;
	}

	.bw_footer {
		box-sizing: border-box;
		display: flex;
		position: fixed;
		bottom: 0;
		left: 0;
		padding: 6px 14px 10px;
		border-top: 1px solid #e6e3e8;
		width: 100%;
		height: 60px;
		background-color: #F1F1F1;
		justify-content: space-between;
		align-items: center;
	}

	.bw_footer_item {
		cursor: pointer;
		display: flex;
		width: 50px;
		height: 44px;
		flex-direction: column;
		align-items: center;
	}

	.bw_footer_item>image {
		width: 28px;
		height: 28px;
	}

	.bw_footer_item>text {
		font-size: 12px;
		color: #191919;
	}

	.bw_footer_item>.active {
		color: #289adb;
	}
</style>
